<?php
/**
 * Created by PhpStorm.
 * User: Jay
 * Date: 2018/5/27
 * Time: 20:39
 */

namespace app\index\controller;

use app\common\controller\Frontend;
use app\common\library\Token;

class Master extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';

    public function _initialize()
    {
        parent::_initialize();
    }

    public function index()
    {
        $masterModel = model('Master');
        $masterList = $masterModel->field('id,name,details,head')->select();

        $this->view->assign("masterlist", $masterList);
        $this->view->assign("nav", 'master');

        return $this->view->fetch();
    }

    /**
     * 大师详情
     * @return string
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function info()
    {

        $id = $this->request->param('id/s');
        $masterModel = model('Master');
        $masterList = $masterModel->field('id,name')->select();
        $info = collection($masterModel->where('id', $id)->select())->toArray();

        $this->view->assign('list', $masterList);
        $this->view->assign("info", $info[0]);

        return $this->view->fetch();
    }

}
